package test.pcs;

import com.payment.lc.pcs.client.wrap.bo.ProductionTimeAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionValueAttributes;
import com.payment.lc.pcs.client.wrap.model.ZiGuanTime;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.service.api.DynamicDataService;
import com.payment.lc.pcs.service.api.ProductionService;
import com.payment.lc.pcs.service.domain.FundsProduction;
import com.payment.lc.pcs.service.domain.Production;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import test.BaseTest;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created on 2016/8/8.
 */
public class Demo2PcsTestZiGuan extends BaseTest {
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    private SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Autowired
    ProductionService productionService;
    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    DynamicDataService dynamicDataService;

    @Test
    public void test() {
        test3();
//        test2();
//        test9();
    }

    void test3(){
        Production production = productionService.getProduction("SF2883");
        print(production);
    }

    void test2(){
        String prodCode = "SF3508";
        Production production = productionWrapService.getProduction(prodCode);
        ProductionTimeAttributes timeAttributes = productionWrapService.getProductionTimeAttributes(production, false);
        print(timeAttributes);

        ProductionValueAttributes valueAttributes = productionWrapService.getProductionValueAttributes(production);
        print(valueAttributes);
    }

    void test9() {
        try {
            Date date = sdf1.parse("2017-2-22 9:41:49");
            String prodCode = "SF2885";
            Production production = productionWrapService.getProduction(prodCode);

            ProductionTimeAttributes productionTimeAttributes = productionWrapService.getProductionTimeAttributes(production);
            print(productionTimeAttributes);

            ZiGuanTime targetZiGuanTime = productionWrapService.getTargetZiGuanTime(prodCode, date);
            if (targetZiGuanTime != null) {
                System.out.println(sdf1.format(targetZiGuanTime.getPurOpenTime()));
            }else{
                print(targetZiGuanTime);
            }

            ZiGuanTime ziGuanPeriod = productionWrapService.getZiGuanPeriod(prodCode, date);
            print(sdf1.format(ziGuanPeriod.getPurOpenTime()));


        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

    void test1() {
        String prodCode = "SF3508";
        Production production = productionWrapService.getProduction(prodCode);
        ProductionValueAttributes valueAttributes = productionWrapService.getProductionValueAttributes(production);
        print(valueAttributes);
    }


}